﻿using System;
using System.Linq;
using System.Security.Principal;

namespace IrisMembership.Web.Authentication
{
    public class IrisPrincipal : IPrincipal
    {
        private readonly IrisIdentity _identity;

        public IrisPrincipal(IrisIdentity identity)
        {
            _identity = identity;
        }

        #region IPrincipal Members

        public bool IsInRole(string role)
        {
            // TODO : fix user is in role by connecting to database and fetch user roles
            return true;
        }

        public IIdentity Identity
        {
            get { return _identity; }
        }

        public IrisIdentity Information
        {
            get { return _identity; }
        }

        public bool IsUser
        {
            get { return !IsGuest; }
        }

        public bool IsGuest
        {
            get { return _identity.Role == "guest"; }
        }

        #endregion
    }
}